<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c"       uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page isELIgnored="false"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
     <meta http-equiv="content-Type" content="text/html; charset=utf-8" />
    <title>用户信息设置</title>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<meta http-equiv="keywords" content="blog,图片,david" />
	<meta http-equiv="description" content="This is my web blog" />
	
<link href="<%=path %>/themes/css/index.css" rel="stylesheet" type="text/css" />
<link href="<%=path %>/themes/css/pmanager.css" rel="stylesheet" type="text/css" />
 
   <script type="text/javascript" src="<%=path %>/script/jquery.js"></script>
 
<style type="text/css">
.warning{

}
.code{
  font-size:12px;
}

</style>
<script type="text/javascript">
 //提交，最终验证。
 $(function(){ 
 //初始化城市
 var city = $('#nowHome_1').val();
		if(city==null||city==''){
		$("#nowHome").attr("value",'北京');
		}else{
		$("#nowHome").attr("value",city);
		}
 
  $('form :input').blur(function(){
	         var id = $(this).attr("id");
             $(this).removeClass("warning").parents("td")
			 .find("span.error").remove()
			 .end()
			 .find("span.ok").remove();

		     var $listItem =  $(this).parents("td").find("span:last");
 
           //验证昵称
			 if( id == 'byname' ){
			 	var byname = $(this).attr("value");
				if($(this).attr("value") == null || $(this).attr("value") == ''){
                      var errorMsg = '请输入昵称！';
					  $('<span class="error"></span>').css("color","red")
					  $(this).parent().next().text(errorMsg)
					  .appendTo($listItem);
					 
					  $(this).addClass("warning");
				}else{
				       var okMsg = '';
                       $(this).parent().next().text(okMsg)
				   }
				}
		      })
 
		$("#tijiao").bind("click", function(){
		$(":input").trigger('blur');
		
			var numWarning = $('.warning',$('form')).length;
			
            if(numWarning){
			    var errorFieldList = [];
                $(".warning").each(function(){
					errorFieldList.push( $(this).prev("span").text() );
				})
				
				return false;
			}  
			var byname =  $('#byname').val();
			var nowHome =  $('#nowHome').val();
			var activeArea =  $('#activeArea').val();
			var homeplace =  $('#homeplace').val();
			var intoduce =  $('#intoduce').text();
			var sendData="byname="+encodeURIComponent(byname)+"&nowHome="+encodeURIComponent(nowHome)+"&activeArea="+encodeURIComponent(activeArea)+"&homeplace="+encodeURIComponent(homeplace)+"&intoduce="+encodeURIComponent(intoduce);
			$.ajax({
            type:"POST",
            url: "<%=request.getContextPath()%>/updateUserinfo.do", 
            dataType:'html', //接受数据格式
            async: false,
            data: sendData,

            success: function(data){ 
            if(data=='true'){ 
                    $("#loadtip2").show();  
                  }else{              
                  $('#byname').parent().next().html("<font color='red'>用户名以存在!</font>");
                }
                },
           error:function(data){
             alert(data);
           }
            }) 
      });
      
      $("#tijiao2").bind("click", function(){
		$(":input").trigger('blur');
		
			var numWarning = $('.warning',$('form')).length;
			
            if(numWarning){
			    var errorFieldList = [];
                $(".warning").each(function(){
					errorFieldList.push( $(this).prev("span").text() );
				})
				
				return false;
			}  
			var byname =  $('#byname').val();
			var nowHome =  $('#nowHome').val();
			var activeArea =  $('#activeArea').val();
			var homeplace =  $('#homeplace').val();
			var intoduce =  $('#intoduce').text();
			var sendData="byname="+encodeURIComponent(byname)+"&nowHome="+encodeURIComponent(nowHome)+"&activeArea="+encodeURIComponent(activeArea)+"&homeplace="+encodeURIComponent(homeplace)+"&intoduce="+encodeURIComponent(intoduce);
			$.ajax({
            type:"POST",
            url: "<%=request.getContextPath()%>/updateUserinfo.do", 
            dataType:'html', //接受数据格式
            async: false,
            data: sendData,

            success: function(data){ 
            if(data=='true'){ 
                   
                  }else{              
                  $('#byname').parent().next().html("<font color='red'>用户名以存在!</font>");
                }
                },
           error:function(data){
             alert(data);
           }
            }) 
      });
       }) 
       
function refrash(){
		$('#imgId')[0].src+='?'+Math.floor(Math.random()*10);
		}
</script>
</head> 
<body>
  <%@ include file="../../../../common/header.jsp"%>
<div id="container">
<div id="mainbody">
  <div id="managerleftbody">
     <h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;我的设置</h2>
	  <ul>
	    <li class="lefttitle">信息设置</li>
	   <li> 基本信息 </li>
	   <li><a href="<%=request.getContextPath()%>/pages/topics/usermanager/updateUserface.jsp">更换头像</a></li>
	   <li><a href="<%=request.getContextPath()%>/moreUserinfo.do">详细信息</a></li>
		 <li><a href="<%=request.getContextPath()%>/useraccount.do">帐户设置</a></li> 
	  </ul>
	  
	  <ul>
	    <li class="lefttitle">作品管理</li>
	  <li><a href="<%=request.getContextPath()%>/usertopicmanager.do">发布的作品</a></li>
	   <li><a href="<%=request.getContextPath()%>/usercollect.do">收藏的作品</a></li>
	   <li><a href="<%=request.getContextPath()%>/usercomment.do">评论的作品</a></li> 
	  </ul>
	   <ul>
	    <li class="lefttitle">站内动态</li>
	   <li><a href="javascript:alert('功能暂未启用')">全站动态</a></li>
		 <li><a href="javascript:alert('功能暂未启用')">我的好友</a></li>
	   <li><a href="javascript:alert('功能暂未启用')">好友动态</a></li>
	    
	  </ul>
  </div>
   <div id="managerrightbody">
	   <div class="ClassTitle">基本信息设置</div>
	   <form method="post" action="">
		<table>
		 <tr><td>
	 <div style="display:none;" id="loadtip2"><img src="<%=path%>/themes/images/success.gif"　width="30px" height="20px"/><font color="red">基本信息设置成功</font></div> 
	 </td></tr>
		  <tr>
		   <td>昵称:</td><td><input type="text" name="byname"  id="byname" value="${user.byname}"/></td><td class="regtip"></td>
		  </tr>
		   <tr>
		   
		   
		   <%
		  User user = (User)session.getAttribute(TuEyeConstant.TUEYE_USER);
		   if(user == null){
		   request.getRequestDispatcher("userlogin.jsp").forward(request,response);
		   }else{
	   %>     
	       
	       <%  
                  if(user.getUserPoto()==null||"".equals(user.getUserPoto())){ 
           %> 
                 <td>头像:</td><td><img src="<%=path%>/pages/topics/usermanager/userphoto/userphoto.jpg" width="96" height="96" /><a href="<%=request.getContextPath()%>/pages/topics/usermanager/updateUserface.jsp">更改头像</a></td>
           <% 
                  }else    
                {%> 
               <td>头像:</td><td><img alt="" src="<%=request.getContextPath() %>/pages/topics/usermanager/userphoto/${user.userPoto}" width="96" height="96" /><a href="<%=request.getContextPath()%>/pages/topics/usermanager/updateUserface.jsp">更改头像</a></td>
           <%}}%>  
		   
		  </tr>
		   <tr>
		   <input type="hidden" id= "nowHome_1" value="${user.nowHome}"/>
		   <td>现居地:</td><td>
          <select name="nowHome" id="nowHome"><option value="北京">B北京</option>
	 <option value="长春">C长春</option>
	<option value="长沙">C长沙</option>
	<option value="成都">C成都</option>
	<option value="重庆">C重庆</option>
	<option value="大连">D大连</option>
	<option value="东莞">D东莞</option>
	<option value="佛山">F佛山</option>
	<option value="福州">F福州</option>
	<option value="广州">G广州</option>
	<option value="贵阳">G贵阳</option>
	<option value="哈尔滨">H哈尔滨</option>
	<option value="海南">H海南</option>
	<option value="杭州">H杭州</option>
	<option value="合肥">H合肥</option>
	<option value="呼和浩特">H呼和浩特</option>
	<option value="济南">J济南</option>
	<option value="昆明">K昆明</option>
	<option value="兰州">L兰州</option>
	<option value="南昌">N南昌</option>
	<option value="南京">N南京</option>
	<option value="南宁">N南宁</option>
	<option value="宁波">N宁波</option>
	<option value="青岛">Q青岛</option>
	<option value="上海">S上海</option>
	<option value="沈阳">S沈阳</option>
	<option value="深圳">S深圳</option>
	<option value="石家庄">S石家庄</option>
	<option value="苏州">S苏州</option>
	<option value="太原">T太原</option>
	<option value="天津">T天津</option>
	<option value="武汉">W武汉</option>
	<option value="乌鲁木齐">W乌鲁木齐</option>
	<option value="无锡">W无锡</option>
	<option value="厦门">X厦门</option>
	<option value="西安">X西安</option>
	<option value="西宁">X西宁</option>
	<option value="扬州">Y扬州</option>
	<option value="郑州">Z郑州</option>
	<option value="珠海">Z珠海</option>
	<option value="其它城市">M其它城市</option>
	</select>

          </td>
		  </tr>
		   <tr>
		   <td>活动区域:</td><td><input type="text" name="activeArea" id="activeArea" value="${user.activeArea}" /></td>
		  </tr>
		  <tr>
		   <td>出生地:</td><td><input type="text" name="homeplace" id="homeplace" value="${user.homeplace}"/></td>
		  </tr>
		  <tr>
		   <td>自我介绍:</td><td><textarea   name="intoduce" id="intoduce" cols="30" rows="6" >${user.intoduce}</textarea>
        </td>
		  </tr>
		  <tr>
		   <td  colspan="2" align="center"><br /><input type="button"  id="tijiao" value="提交" /><input type="button" value="下一步" id="tijiao2" onclick= "window.location.href='<%=request.getContextPath()%>/moreUserinfo.do'"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
		  </tr>
		</table>
		</form>
	</div>
 </div> </div>
<%@ include file="../../../../common/footer.jsp" %>

</body>
</html>

